Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

phone

Package Overview
Dependencies
Maintainers
2
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phone

With a given country and phone number, validate and format the phone number to E.164 standard

  • 3.1.56
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
202K
increased by3.5%
Maintainers
2
Weekly downloads
 
Created

What is phone?

The 'phone' npm package is a utility for parsing, validating, and formatting phone numbers. It helps in handling phone numbers in various formats and ensures they are in a consistent and usable format.

What are phone's main functionalities?

Parsing and Formatting Phone Numbers

This feature allows you to parse and format phone numbers into a standard E.164 format. The function returns an array where the first element is the formatted phone number and the second element is the country code.

const phone = require('phone');
const result = phone('+1 (123) 456-7890');
console.log(result); // ['+11234567890', 'USA']

Handling Different Country Codes

You can specify a country code to parse phone numbers according to the rules of that country. This is useful for handling international phone numbers.

const phone = require('phone');
const result = phone('1234567890', 'GB');
console.log(result); // ['+441234567890', 'GB']

Validating Phone Numbers

The package can also be used to validate phone numbers. If the phone number is invalid, it returns an empty array.

const phone = require('phone');
const result = phone('1234567890', 'USA');
console.log(result); // []

Other packages similar to phone

Keywords

FAQs

Package last updated on 16 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc